package com.lp.biz.operations.model.vo;

import com.lp.biz.operations.model.entity.Invoice;
import lombok.Data;

import java.math.BigDecimal;

import static com.lp.common.utils.Tools.stripTrailingZeros;

/**
 * @program: backend
 * @description:
 * @author: Ke.Song
 * @since: 2024-07-17 21:20:25
 */
@Data
public class InvoiceList {

    private Integer id;

    private Integer titleType;

    private String title;

    /**
     * 纳税人识别号
     */
    private String taxpayerIdentificationNumber;

    /**
     * 总金额
     */
    private BigDecimal totalAmount;

    /**
     * 企业地址
     */
    private String businessAddress;

    /**
     * 企业电话
     */
    private String businessPhone;

    /**
     * 开户银行
     */
    private String bankAccountHolder;

    /**
     * 银行账户
     */
    private String bankAccount;

    /**
     * 邮箱
     */
    private String email;

    private Integer status;

    public static InvoiceList builder(Invoice invoice) {
        InvoiceList invoiceList = new InvoiceList();
        invoiceList.setId(invoice.getId());
        invoiceList.setTitleType(invoice.getTitleType());
        invoiceList.setTitle(invoice.getTitle());
        invoiceList.setTaxpayerIdentificationNumber(invoice.getTaxpayerIdentificationNumber());
        invoiceList.setTotalAmount(stripTrailingZeros(invoice.getTotalAmount()));
        invoiceList.setBusinessAddress(invoice.getBusinessAddress());
        invoiceList.setBusinessPhone(invoice.getBusinessPhone());
        invoiceList.setBankAccountHolder(invoice.getBankAccountHolder());
        invoiceList.setBankAccount(invoice.getBankAccount());
        invoiceList.setEmail(invoice.getEmail());
        invoiceList.setStatus(invoice.getStatus());
        return invoiceList;
    }
}
